package com.example.guestbookmybatis.controller;


import com.example.guestbookmybatis.domain.Message;
import com.example.guestbookmybatis.domain.User;
import com.example.guestbookmybatis.service.BookService;
import com.example.guestbookmybatis.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;
import java.util.List;

@Controller
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping("/login")
    public String login(User user, HttpSession session){
        if(userService.check(user) == true){
            session.setAttribute("account",user);
            System.out.println("登录成功");
        }
        return "redirect:/book/index";
    }
}
